function checkPublicB(){
    var o = document.publicB;
    if(o.title.value==""){
        o.title.focus();
        alert("标题不能空！");
        return false;
    }else if(getEditorTextContents('content')==''){
        alert("内容不能空！");
        return false;
    }
    return true;
}

function checkPublicC(){
    var o = document.publicC;
    if(o.title.value==""){
        o.title.focus();
        alert("标题不能空！");
        return false;
    }else if(o.image.value==''){
        o.image.focus();
        alert("请选择您想上传的图片！");
        return false;
    }else if(!isValidImg(o.image.value)){
        o.image.focus();
        alert("只支持格式为“png,gif,jpg,bmp”的图片！");
        return false;
    }
    return true;
}

function checkPublicC2(){
    var o = document.publicC;
    if(o.title.value==""){
        o.title.focus();
        alert("标题不能空！");
        return false;
    }else if(o.image.value!=''){
        if(!isValidImg(o.image.value)){
            o.image.focus();
            alert("只支持格式为“png,gif,jpg,bmp”的图片！");
            return false;
        }
    }
    return true;
}

function checkPublicD(){
    var o = document.publicD;
    if(o.name.value==""){
        o.name.focus();
        alert("教师姓名不能空！");
        return false;
    }else if(o.birthday.value==""){
        o.birthday.focus();
        alert("教师出生日期不能空！");
        return false;
    }else if(o.photo.value!=''){
        if(!isValidImg(o.photo.value)){
            o.photo.focus();
            alert("只支持格式为“png,gif,jpg,bmp”的图片！");
            return false;
        }
    }
    return true;
}

function checkPublicE(){
    var o = document.publicE;
    if(o.title.value==""){
        o.title.focus();
        alert("文件名不能空！");
        return false;
    }else if(o.file.value==''){
        o.file.focus();
        alert("请选择您想上传的文件！");
        return false;
    }else if(!isValidFile(o.file.value)){
        o.file.focus();
        alert("只支持格式为“zip,rar,tar,gz,doc,docx,ppt,pptx,xls,xlsx,png,gif,jpg,bmp,pdf,txt,htm,html”的文件！");
        return false;
    }
    return true;
}

function checkPublicE2(){
    var o = document.publicE;
    if(o.title.value==""){
        o.title.focus();
        alert("文件名不能空！");
        return false;
    }else if(o.file.value!=''){
        if(!isValidFile(o.file.value)){
            o.file.focus();
            alert("只支持格式为“zip,rar,tar,gz,doc,docx,ppt,pptx,xls,xlsx,png,gif,jpg,bmp,pdf,txt,htm,html”的文件！");
            return false;
        }
    }
    return true;
}

function isValidImg(img){
    if(!img){
        return false;
    }
    img = img.toLowerCase();
    if(img.endWith("gif")||img.endWith("jpg")||img.endWith("bmp")||img.endWith("png")){
        return true;
    }
    return false;
}

function isValidFile(o){
    if(!o){
        return false;
    }
    o = o.toLowerCase();
    if(o.endWith("zip")||o.endWith("rar")||o.endWith("tar")||o.endWith("gz")||
        o.endWith("doc")||o.endWith("docx")||o.endWith("ppt")||o.endWith("pptx")||o.endWith("xls")||o.endWith("xlsx")||
        o.endWith("gif")||o.endWith("jpg")||o.endWith("bmp")||o.endWith("png")||
        o.endWith("pdf")||o.endWith("txt")||o.endWith("htm")||o.endWith("htm")){
        return true;
    }
    return false;
}

function deletePublicXX(id,form){
    var v = eval("document."+form);

    var xs="";
    for (var i=0;i<v.elements.length;i++) {
        var temp=v[i];

        if(temp.type=="checkbox"&&(!temp.disabled)&&temp.checked) {
            xs+= temp.value+",";
        }
    }

    if(xs==""){
        alert("请先选择您需要删除的选项！");
    }else if(confirm("您确定要删除选择的选项吗？")){
        manage.deletePublicXX(id,xs,function(data){
            if(data==1){
                alert("成功删除ID=“"+xs+"”的选项");
                window.location.reload();
            }else if(data==-1){
                alert("部分选中的选项删除失败");
            }else if(data==0){
                alert("未知原因，选项删除失败");
            }
        });
    }
}

// 获取编辑器中文字内容
function getEditorTextContents(EditorName) {
    var oEditor = FCKeditorAPI.GetInstance(EditorName);
    return(oEditor.EditorDocument.body.innerText);
}